package org.xteam.sled.model;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.xteam.sled.semantic.exp.Exp;

public class AbsoluteProtoDisjunct extends AbsoluteDisjunct {

	private Map<AbsoluteField, Exp> fieldBindings = new HashMap<AbsoluteField, Exp>();
	
	public AbsoluteProtoDisjunct(String name, Set<Exp> conditions,
			AbsoluteSequence seq, Map<AbsoluteField, Exp> bb) {
		super(name, conditions, seq);
		this.fieldBindings = bb;
	}
	
	public AbsoluteProtoDisjunct(String name, Set<Exp> conds,
			AbsoluteSequence seq) {
		super(name, conds, seq);
	}
	
	public AbsoluteProtoDisjunct(AbsoluteSequence seq) {
		super(null, new HashSet<Exp>(), seq);
	}

	@Override
	protected BaseDisjunct<AbsoluteSequence> createDisjunct(String name,
			Set<Exp> conds, ISequence seq) {
		return new AbsoluteProtoDisjunct(name, conds, (AbsoluteSequence) seq);
	}

	public Map<AbsoluteField, Exp> getFieldBindings() {
		return fieldBindings;
	}
	
	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		if (name != null)
			buffer.append(name).append("=");
		buffer.append(fieldBindings);
		if (conditions.size() > 0) {
			buffer.append("{");
			boolean isFirst = true;
			for (Exp e : conditions) {
				if (! isFirst)
					buffer.append(", ");
				buffer.append(e);
			}
			buffer.append("}");
		}
		buffer.append(sequence.toString());
		return buffer.toString();
	}
	
}


